﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public static class Helper
{
    public static String serverPath;

    public static String productImageDirectory;

    public static String productImageDirectoryTemp;

    public static Decimal FeeOfRaoVatThuong
    {
        get { return Decimal.Parse(ConfigurationManager.AppSettings["Fee_RaoVat_Thuong"]); }
    }

    public static Int32 TimeLineOfRaoVatThuong
    {
        get { return Int32.Parse(ConfigurationManager.AppSettings["TimeLine_RaoVat_Thuong"]); }
    }

    public static Decimal FeeOfRaoVatVIP
    {
        get { return Decimal.Parse(ConfigurationManager.AppSettings["Fee_RaoVat_VIP"]); }
    }

    public static Int32 TimeLineOfRaoVatVIP
    {
        get { return Int32.Parse(ConfigurationManager.AppSettings["TimeLine_RaoVat_VIP"]); }
    }

    public static Decimal MoneyForNewUser
    {
        get { return Decimal.Parse(ConfigurationManager.AppSettings["Money_NewUser"]); }
    }

    const string FindText = "áàảãạâấầẩẫậăắằẳẵặđéèẻẽẹêếềểễệíìỉĩịóòỏõọôốồổỗộơớờởỡợúùủũụưứừửữựýỳỷỹỵÁÀẢÃẠÂẤẦẨẪẬĂẮẰẲẴẶĐÉÈẺẼẸÊẾỀỂỄỆÍÌỈĨỊÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢÚÙỦŨỤƯỨỪỬỮỰÝỲỶỸỴ/:";
    const string ReplText = "aaaaaaaaaaaaaaaaadeeeeeeeeeeeiiiiiooooooooooooooooouuuuuuuuuuuyyyyyAAAAAAAAAAAAAAAAADEEEEEEEEEEEIIIIIOOOOOOOOOOOOOOOOOUUUUUUUUUUUYYYYY_ ";
    /// <summary>
    /// Chuyển từ dạng tiếng việt có dấu sang không dấu
    /// </summary>
    /// <param name="strVietNamese">chuỗi tiếng việt có dấu</param>
    /// <returns>chuỗi tiếng việt không dấu</returns>
    public static string ChuyenTVKhongDau(string strVietNamese)
    {
        strVietNamese = strVietNamese.Replace("-", "");
        strVietNamese = strVietNamese.Replace(".", "");
        strVietNamese = strVietNamese.Replace("%", "");
        int index = -1;
        while ((index = strVietNamese.IndexOfAny(FindText.ToCharArray())) != -1)
        {
            int index2 = FindText.IndexOf(strVietNamese[index]);
            strVietNamese = strVietNamese.Replace(strVietNamese[index], ReplText[index2]);
        }
        return strVietNamese;
    }
}
